<html><head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Analysis" rel="Chapter" href="Analysis.html">
<link title="Ast" rel="Chapter" href="Ast.html">
<link title="Ast_info" rel="Chapter" href="Ast_info.html">
<link title="Environment" rel="Chapter" href="Environment.html">
<link title="Expression" rel="Chapter" href="Expression.html">
<link title="Filename_util" rel="Chapter" href="Filename_util.html">
<link title="Interpreter" rel="Chapter" href="Interpreter.html">
<link title="Jtemplate" rel="Chapter" href="Jtemplate.html">
<link title="Lexer" rel="Chapter" href="Lexer.html">
<link title="Library" rel="Chapter" href="Library.html">
<link title="Library_builtin" rel="Chapter" href="Library_builtin.html">
<link title="Library_io" rel="Chapter" href="Library_io.html">
<link title="Library_string" rel="Chapter" href="Library_string.html">
<link title="Parser" rel="Chapter" href="Parser.html">
<link title="Parser_util" rel="Chapter" href="Parser_util.html">
<link title="RuntimeError" rel="Chapter" href="RuntimeError.html"><title>Filename_util.resolve_filename</title>
</head>
<body>
<code class="code"><span class="keyword">let</span>&nbsp;resolve_filename&nbsp;dir&nbsp;filename&nbsp;=<br>
&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;<span class="keyword">rec</span>&nbsp;cleanup&nbsp;check&nbsp;ok&nbsp;=<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;right&nbsp;=&nbsp;<span class="constructor">Filename</span>.basename&nbsp;check&nbsp;<span class="keyword">in</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;left&nbsp;=&nbsp;<span class="constructor">Filename</span>.dirname&nbsp;check&nbsp;<span class="keyword">in</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;(right&nbsp;=<span class="string">"."</span>&nbsp;<span class="keywordsign">&amp;&amp;</span>&nbsp;<span class="constructor">Filename</span>.dirname&nbsp;left&nbsp;=&nbsp;left)&nbsp;<span class="keyword">then</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="constructor">Filename</span>.concat&nbsp;left&nbsp;ok<br>
&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">else</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">match</span>&nbsp;right&nbsp;<span class="keyword">with</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keywordsign">|</span>&nbsp;<span class="string">"."</span>&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;cleanup&nbsp;left&nbsp;ok<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keywordsign">|</span>&nbsp;<span class="string">".."</span>&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;cleanup&nbsp;(<span class="constructor">Filename</span>.dirname&nbsp;left)&nbsp;ok<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keywordsign">|</span>&nbsp;<span class="string">""</span>&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;ok<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keywordsign">|</span>&nbsp;_&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;cleanup&nbsp;left&nbsp;(<span class="keyword">if</span>&nbsp;ok&nbsp;=<span class="string">""</span>&nbsp;<span class="keyword">then</span>&nbsp;right&nbsp;<span class="keyword">else</span>&nbsp;<span class="constructor">Filename</span>.concat&nbsp;right&nbsp;ok)<br>
&nbsp;&nbsp;<span class="keyword">in</span><br>
&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;<span class="constructor">Filename</span>.is_relative&nbsp;filename&nbsp;<span class="keyword">then</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;cleanup&nbsp;(<span class="constructor">Filename</span>.concat&nbsp;dir&nbsp;filename)&nbsp;<span class="string">""</span><br>
&nbsp;&nbsp;<span class="keyword">else</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;filename</code></body></html>